import jsonp from 'common/jsonp.js'
import {commonParams, options} from './config.js'
import axios from 'axios'
export function getRecommend () {
  const url = 'https://c.y.qq.com/musichall/fcgi-bin/fcg_yqqhomepagerecommend.fcg'

  const data = Object.assign({}, commonParams, {
    platform: 'h5',
    uin: 0,
    needNewCode: 1
  })

  return jsonp(url, data, options)
}

export function getDiscList() {
  const url = '/api/getDiscList'

  const data = Object.assign({}, {
    picmid: 1,
    rnd: 0.774641028432451,
    g_tk: 5381,
    loginUin: 0,
    hostUin: 0,
    format: 'json',
    inCharset: 'utf8',
    outCharset: 'utf-8',
    notice: 0,
    platform: 'yqq.json',
    needNewCode: 0,
    categoryId: 10000000,
    sortId: 5,
    sin: 0,
    ein: 19,
    format: 'json'
  })
  return axios.get(url, {
    params: data
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}

export function getDiscSongList(disstid) {
  const url = '/api/getDiscSongList'

  const data = {
    type: 1,
    json: 1,
    utf8: 1,
    onlysong: 0,
    new_format: 1,
    disstid: `${disstid}`,
    g_tk: 5381,
    hostUin: 0,
    format: 'json',
    inCharset: 'utf8',
    outCharset: 'utf-8',
    notice: 0,
    platform: 'yqq.json',
    needNewCode: 0
  }
  return axios.get(url, {
    params: data
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}

//推荐歌曲

export function getRecommendList() {
  const url = '/api/getRecommendList'

  const data = {
    '-': 'recom7403898780877847',
    g_tk: 5381,
    hostUin: 0,
    format: 'json',
    inCharset: 'utf8',
    outCharset: 'utf-8',
    notice: 0,
    platform: 'yqq.json',
    needNewCode: 0,
	data: {
		"comm": {
			"ct": 24
		},
		"category": {
			"method": "get_hot_category",
			"param": {
				"qq": ""
			},
			"module": "music.web_category_svr"
		},
		"recomPlaylist": {
			"method": "get_hot_recommend",
			"param": {
				"async": 1,
				"cmd": 2
			},
			"module": "playlist.HotRecommendServer"
		},
		"playlist": {
			"method": "get_playlist_by_category",
			"param": {
				"id": 8,
				"curPage": 1,
				"size": 40,
				"order": 5,
				"titleid": 8
			},
			"module": "playlist.PlayListPlazaServer"
		},
		"new_song": {
			"module": "newsong.NewSongServer",
			"method": "get_new_song_info",
			"param": {
				"type": 5
			}
		},
		"new_album": {
			"module": "newalbum.NewAlbumServer",
			"method": "get_new_album_info",
			"param": {
				"area": 1,
				"sin": 0,
				"num": 10
			}
		},
		"new_album_tag": {
			"module": "newalbum.NewAlbumServer",
			"method": "get_new_album_area",
			"param": {}
		},
		"toplist": {
			"module": "musicToplist.ToplistInfoServer",
			"method": "GetAll",
			"param": {}
		},
		"focus": {
			"module": "QQMusic.MusichallServer",
			"method": "GetFocus",
			"param": {}
		}
    }
  }
  return axios.get(url, {
    params: data
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}